<template>
    <div>
        <el-row :gutter="15">
            <el-form
                ref="elForm"
                :model="formData"
                size="small"
                label-width="100px"
            >
                <!-- :rules="rules" -->

                <el-col :span="12">
                    <el-row :gutter="15">
                        <el-col :span="24">
                            <el-form-item
                                label-width="160px"
                                label="票据号"
                                prop="billNo"
                            >
                                <el-input
                                    v-model="formData.billNo"
                                    placeholder="请输入票据号"
                                    clearable
                                    :style="{ width: '100%' }"
                                >
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item
                                label-width="160px"
                                label="票据类型"
                                prop="billType"
                            >
                                <el-input
                                    v-model="formData.billType"
                                    placeholder="请输入票据类型"
                                    clearable
                                    :style="{ width: '100%' }"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item
                                label-width="160px"
                                label="贴现金额"
                                prop="discountAmount"
                            >
                                <el-input
                                    v-model="formData.discountAmount"
                                    placeholder="请输入贴现金额"
                                    clearable
                                    :style="{ width: '100%' }"
                                >
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item
                                label-width="160px"
                                label="实收金额"
                                prop="dueAmount"
                            >
                                <el-input
                                    v-model="formData.dueAmount"
                                    placeholder="请输入实收金额"
                                    clearable
                                    :style="{ width: '100%' }"
                                >
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item
                                label-width="160px"
                                label="贴现银行"
                                prop="discountBank"
                            >
                                <el-input
                                    v-model="formData.discountBank"
                                    placeholder="请输入贴现银行"
                                    clearable
                                    :style="{ width: '100%' }"
                                >
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item
                                label-width="160px"
                                label="贴现日期"
                                prop="discountDate"
                            >
                                <el-date-picker
                                    v-model="formData.discountDate"
                                    format="yyyy-MM-dd"
                                    value-format="yyyy-MM-dd"
                                    :style="{ width: '100%' }"
                                    placeholder="请选择贴现日期"
                                    clearable
                                ></el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item
                                label-width="160px"
                                label="贴息调整天数"
                                prop="discountDayNumber"
                            >
                                <el-input
                                    v-model="formData.discountDayNumber"
                                    placeholder="请输入贴息调整天数"
                                    clearable
                                    :style="{ width: '100%' }"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-col>
                <el-col :span="12">
                    <el-row :gutter="15">
                        <el-col :span="24">
                            <el-form-item
                                label-width="160px"
                                label="币别"
                                prop="kingBaseCurrencyId"
                            >
                                <el-input
                                    v-model="formData.kingBaseCurrencyId"
                                    placeholder="请输入币别"
                                    clearable
                                    :style="{ width: '100%' }"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item
                                label="费用"
                                label-width="160px"
                                prop="discountFee"
                            >
                                <el-input
                                    v-model="formData.discountFee"
                                    placeholder="请输入费用"
                                    clearable
                                    :style="{ width: '100%' }"
                                >
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item
                                label-width="160px"
                                label="贴现息"
                                prop="discountInterest"
                            >
                                <el-input
                                    v-model="formData.discountInterest"
                                    placeholder="请输入贴现息"
                                    clearable
                                    :style="{ width: '100%' }"
                                >
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item
                                label-width="160px"
                                label="贴现率"
                                prop="discountRate"
                            >
                                <el-input
                                    v-model="formData.discountRate"
                                    placeholder="请输入贴现率"
                                    clearable
                                    :style="{ width: '100%' }"
                                >
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item
                                label="结算号"
                                label-width="160px"
                                prop="discountSettlementNumber"
                            >
                                <el-input
                                    v-model="formData.discountSettlementNumber"
                                    placeholder="请输入结算号"
                                    clearable
                                    :style="{ width: '100%' }"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item
                                label="税额"
                                label-width="160px"
                                prop="discountTax"
                            >
                                <el-input
                                    v-model="formData.discountTax"
                                    placeholder="请输入税额"
                                    clearable
                                    :style="{ width: '100%' }"
                                >
                                </el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-col>
            </el-form>
        </el-row>
    </div>
</template>
<script>
import { discountInfo, getDetail } from "@/api/finance/receivebill";
export default {
    props: ["rowId"],
    data() {
        return {
            formData: {
                billNo: undefined,
                billType: undefined,
                updateTime: null,
                discountAmount: undefined,
                dueAmount: undefined,
                discountBank: undefined,
                discountDate: null,
                discountDayNumber: undefined,
                discountFee: undefined,
                discountInterest: undefined,
                discountRate: undefined,
                discountSettlementNumber: undefined,
                discountTax: undefined,
            },
            // rules: {
            //     billNo: [],
            //     billType: [],
            //     discountAmount: [
            //         {
            //             required: true,
            //             message: "请输入贴现金额",
            //             trigger: "blur",
            //         },
            //     ],
            //     dueAmount: [
            //         {
            //             required: true,
            //             message: "请输入实收金额",
            //             trigger: "blur",
            //         },
            //     ],
            //     discountBank: [
            //         {
            //             required: true,
            //             message: "请输入贴现银行",
            //             trigger: "blur",
            //         },
            //     ],
            //     discountDate: [
            //         {
            //             required: true,
            //             message: "请选择贴现日期",
            //             trigger: "change",
            //         },
            //     ],
            //     discountDayNumber: [
            //         {
            //             required: true,
            //             message: "请输入贴息调整天数",
            //             trigger: "blur",
            //         },
            //     ],
            //     discountFee: [
            //         {
            //             required: true,
            //             message: "请输入费用",
            //             trigger: "blur",
            //         },
            //     ],
            //     discountInterest: [
            //         {
            //             required: true,
            //             message: "请输入贴现息",
            //             trigger: "blur",
            //         },
            //     ],
            //     discountRate: [
            //         {
            //             required: true,
            //             message: "请输入贴现率",
            //             trigger: "blur",
            //         },
            //     ],
            //     discountSettlementNumber: [
            //         {
            //             required: true,
            //             message: "请输入结算号",
            //             trigger: "blur",
            //         },
            //     ],
            //     discountTax: [
            //         {
            //             required: true,
            //             message: "请输入税额",
            //             trigger: "blur",
            //         },
            //     ],
            // },
        };
    },
    methods: {
        submit(cb) {
            this.$refs["elForm"].validate((valid) => {
                if (!valid) return;
                // TODO 提交表单
                if (this.rowId) {
                    discountInfo(this.formData).then((res) => {
                        if (res.code === 200) {
                            this.$message({
                                message: "操作成功！",
                                type: "success",
                            });
                            cb();
                        }
                    });
                }
            });
        },
    },
    mounted() {
        if (this.rowId) {
            console.log(this.rowId);
            getDetail(this.rowId).then((res) => {
                if (res.code === 200) {
                    this.formData = {
                        ...this.formData,
                        ...res.data.kingFinanceReceiptBillEntity,
                    };
                }
            });
        }
    },
};
</script>
<style></style>
